<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectMadaktariMVC.Models.Episode>" %>



<% using (Html.BeginForm())
       { %>
<div id="episodeForm">
    
    <ul>
        <li><a href="#Admit">Admit</a></li>
        <li><a href="#Procedure">Procedure</a></li>
        <li><a href="#Discharge">Discharge</a></li>
        <li><a href="#FollowUp">Follow Up</a></li>
    </ul>
    
    <div id="Admit">
        <input type="submit" value="Save" onclick="$('#tabField').val('Admit')"/>
        <input type="hidden" name="tab" id="tabField" value="" />
        <% if (Model.episodeID != 0)
           {%>
            <%=Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "Admit", new {episodeId = Model.episodeID, patientId = ViewData["patientId"]}, null) %>
        <%}
           else
           { %>
            <%=Html.ActionLink("Cancel", "View","Patient", null, null, "Admit",  new {id = ViewData["patientId"]}, null) %>
        <%} %>
        <div class="form_block">
            <span class="form_label">Admit Date</span>
            <%= Html.TextBox("admitDate", Model.admitDate == null ? "" : ((DateTime)Model.admitDate).ToString("MM/dd/yyyy")  ,new {@class = "datefield"}) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Hospital</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.HospitalDropDown("hospitalID", Model.hospitalID) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Referal Location</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.ReferalLocationDropdown("referalLocationID", Model.referalLocationID) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Diagnosis</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.DiagnosisList("diagnoses", Model.episodeID) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Diagnosis Other</span>
            <%= Html.TextArea("diagnosisOther", Model.diagnosisOther, new { cols = "45", rows = "5" })%>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Concomitant Diagnosis</span>
            <div class="cocomitantChoices">
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.ConcomitantDiagnosisDropDown("concomitantDiagnosis1ID" , Model.concomitantDiagnosisID1) %><br /><br />
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.ConcomitantDiagnosisDropDown("concomitantDiagnosis2ID" , Model.concomitantDiagnosisID2) %>
            </div>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Surgical History</span>
            <%= Html.TextArea("surgicalHistory", Model.surgicalHistory, new { cols = "45", rows = "5" })%>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Case Comments</span>
            <%= Html.TextArea("caseComments", Model.caseComments, new { cols="45", rows="5"}) %>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Image Findings</span>
            <%= Html.TextArea("imageFindings",Model.imageFindings, new {cols="45", rows="5"}) %>
        </div>
        <input type="submit" value="Save" onclick="$('#tabField').val('Admit')"/>
        <% if (Model.episodeID != 0)
           {%>
            <%=Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "Admit", new {episodeId = Model.episodeID, patientId = ViewData["patientId"]}, null) %>
        <%}
           else
           { %>
            <%=Html.ActionLink("Cancel", "View","Patient", null, null, "Admit",  new {id = ViewData["patientId"]}, null) %>
        <%} %>
    </div>
    
    <div id="Procedure">
        <em>Please save episode before adding or editing procedures.</em>
    </div>
    
    <div id="Discharge">
        <input type="submit" value="Save" onclick="$('#tabField').val('Discharge')"/>
        <% if (Model.episodeID != 0)
           {%>
            <%=Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "Discharge", new {episodeId = Model.episodeID, patientId = ViewData["patientId"]}, null) %>
        <%}
           else
           { %>
            <%=Html.ActionLink("Cancel", "View","Patient", null, null, "Discharge",  new {id = ViewData["patientId"]}, null) %>
        <%} %>
        <div class="form_block">
            <span class="form_label">Discharge Date</span>
            <%= Html.TextBox("dischargeDate", Model.dischargeDate == null ? "" : ((DateTime)Model.dischargeDate).ToString("MM/dd/yyyy"), new {@class="datefield"}) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Post-Op Status</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.PostOpStatusDropDown("postOpStatus", Model.postOpStatus) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Days Post Op</span>
            <% if (Model.dischargeDate == null)
               { %>
                <em>number of days will be automatically calculated</em>
            <%}
               else
               { %>
                <%= (DateTime.Today - (DateTime)Model.dischargeDate).Days%> Days
            <%} %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Post-Op Complications</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.ComplicationsRadioButtons("complications", Model.complications) %>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Complications Notes</span>
            <%= Html.TextArea("complicationsNotes", Model.complicationNotes, new {cols="45", rows="5"}) %>
        </div>
        <br />
        <div class="form_block">
            <span class="form_label">Length of Stay</span>
            <% if (Model.admitDate == null || Model.dischargeDate == null)
               {%>
                <em>length of stay will be automatically calculated</em>
            <%}
               else
               { %>
                <%= ((DateTime)Model.dischargeDate - (DateTime)Model.admitDate).Days %> Days
            <%} %>
        </div>
        <input type="submit" value="Save" onclick="$('#tabField').val('Discharge')"/>
        <% if (Model.episodeID != 0)
           {%>
            <%=Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "Discharge", new {episodeId = Model.episodeID, patientId = ViewData["patientId"]}, null) %>
        <%}
           else
           { %>
            <%=Html.ActionLink("Cancel", "View","Patient", null, null, "Discharge",  new {id = ViewData["patientId"]}, null) %>
        <%} %>
    </div>
    
    <div id="FollowUp">
        <input type="submit" value="Save" onclick="$('#tabField').val('FollowUp')"/>
        <% if (Model.episodeID != 0)
           {%>
            <%=Html.ActionLink("Cancel", "ViewEpisode", "Patient", null, null, "FollowUp", new {episodeId = Model.episodeID, patientId = ViewData["patientId"]}, null) %>
        <%}
           else
           { %>
            <%=Html.ActionLink("Cancel", "View","Patient", null, null, "FollowUp",  new {id = ViewData["patientId"]}, null) %>
        <%} %>
        <div class="form_block">
            <span class="form_label">
                Date of Follow-Up
            </span>
            <%= Html.TextBox("followUpDate", Model.followUpDate == null ? "" : ((DateTime)Model.followUpDate).ToString("MM/dd/yyyy"), new {@class="datefield"}) %>
        </div>
        
        <div class="form_block">
            <span class="form_label">Follow-Up Status</span>
            <%= ProjectMadaktariMVC.Helpers.ConfigurationHelper.FollowUpStatusDropdown("followUpStatus", Model.followUpStatus) %>
        </div>
        
        
    </div>
    
    <%} %>
    
</div>

<script type="text/javascript">
    $(function() {
        var $tabs = $("#episodeForm").tabs();
        //        if ($tabs.tabs('option', 'selected') == 1){
        //            load: function(event, ui) {
        //                $('a', ui.panel).click(function() {
        //                    $(ui.panel).load(this.href);
        //                    return false;
        //                });
        //            }
        //        }

        $(".datefield").datepicker();
        $("#procedureList").accordion({ active: false, collapsible: true, autoHeight: false });
    });

</script>
